/**
 * Created by walkman on 2017/6/22.
 */

(function () {

  angular.module('WfbPlatformApp').controller('OrderController',
    ['$rootScope', '$scope', '$http', '$compile', 'http', '$q', 'transactionService',
      function ($rootScope, $scope, $http, $compile, http, $q, transactionService) {

        $scope.$on('$viewContentLoaded', function () {
          // initialize core components
        });

        $scope.$on('$includeContentLoaded', function () {

        });

        // 新增参数
        $scope.currentPage = 1;
        $scope.pageSize = 10;
        $scope.total = 0;
        $scope.contents = {};

        $scope.getOrderList = function (pageNo, pageSize) {

          var promise = transactionService.getOrderList({
            'pageNo': pageNo,
            'pageSize': pageSize
          });
          promise.then(function success(result) {
            // console.log(JSON.stringify(result));
            //成功回调
            $scope.contents = result.data;
            // 分页数
            $scope.total = result.totalCount;
          }, function error(error) {//错误回调
            // console.log(JSON.stringify(error));
          });
        };

        $scope.getOrderStatus = function (orderStatus) {

          //'订单状态：1、待发货  2 待签收 3 已签收 4 已退单';
          if (orderStatus == 1) {
            return "待发货";
          } else if (orderStatus == 2) {
            return "待签收";
          } else if (orderStatus == 3) {
            return "已签收";
          } else if (orderStatus == 4) {
            return "已退单";
          } else {
            return "";
          }
        };

        $scope.pageAction = function (message, page, pageSize, total) {

          $scope.getOrderList(page, pageSize);
        };

        $scope.getOrderList($scope.currentPage, $scope.pageSize);


      }]);
})();



